package com.hdax.dm.rabbitMQ;

import com.hdax.dm.feign.order.OrderFeign;
import com.hdax.dm.feign.scheduler.OrderSchedulerFeign;
import com.hdax.dm.feign.scheduler.SchedulerSeatFeign;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 订单超时
 */
@Component
@RabbitListener(queues = "dm_order_cancel")
public class OrderCancel {

    @Autowired
    private OrderFeign orderFeign;
    @Autowired
    private OrderSchedulerFeign orderSchedulerFeign;

    @RabbitHandler
    public void orderCancel(String orderNo){
        String[] split = orderNo.split(":");
        Integer type = orderFeign.updateOrderType(split[1], 1);
        if (type >= 1){
            orderSchedulerFeign.timeOutUpdateStart(split[1]);
        }
        System.out.println("订单超时，已取消！");
    }

}
